import 'package:oramemo/generated/json/base/json_convert_content.dart';
import 'package:oramemo/entity/country_code_entity.dart';

CountryCodeEntity $CountryCodeEntityFromJson(Map<String, dynamic> json) {
  final CountryCodeEntity countryCodeEntity = CountryCodeEntity();
  final String? msg = jsonConvert.convert<String>(json['msg']);
  if (msg != null) {
    countryCodeEntity.msg = msg;
  }
  final int? code = jsonConvert.convert<int>(json['code']);
  if (code != null) {
    countryCodeEntity.code = code;
  }
  final List<CountryCodeData>? data = (json['data'] as List<dynamic>?)
      ?.map(
          (e) => jsonConvert.convert<CountryCodeData>(e) as CountryCodeData)
      .toList();
  if (data != null) {
    countryCodeEntity.data = data;
  }
  return countryCodeEntity;
}

Map<String, dynamic> $CountryCodeEntityToJson(CountryCodeEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['msg'] = entity.msg;
  data['code'] = entity.code;
  data['data'] = entity.data?.map((v) => v.toJson()).toList();
  return data;
}

extension CountryCodeEntityExtension on CountryCodeEntity {
  CountryCodeEntity copyWith({
    String? msg,
    int? code,
    List<CountryCodeData>? data,
  }) {
    return CountryCodeEntity()
      ..msg = msg ?? this.msg
      ..code = code ?? this.code
      ..data = data ?? this.data;
  }
}

CountryCodeData $CountryCodeDataFromJson(Map<String, dynamic> json) {
  final CountryCodeData countryCodeData = CountryCodeData();
  final CountryCodeDataParams? params = jsonConvert.convert<
      CountryCodeDataParams>(json['params']);
  if (params != null) {
    countryCodeData.params = params;
  }
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    countryCodeData.id = id;
  }
  final String? countryName = jsonConvert.convert<String>(json['countryName']);
  if (countryName != null) {
    countryCodeData.countryName = countryName;
  }
  final String? countryNameZh = jsonConvert.convert<String>(
      json['countryNameZh']);
  if (countryNameZh != null) {
    countryCodeData.countryNameZh = countryNameZh;
  }
  final String? countryCode = jsonConvert.convert<String>(json['countryCode']);
  if (countryCode != null) {
    countryCodeData.countryCode = countryCode;
  }
  final String? countryNameEn = jsonConvert.convert<String>(
      json['countryNameEn']);
  if (countryNameEn != null) {
    countryCodeData.countryNameEn = countryNameEn;
  }
  final String? nationalFlag = jsonConvert.convert<String>(
      json['nationalFlag']);
  if (nationalFlag != null) {
    countryCodeData.nationalFlag = nationalFlag;
  }
  return countryCodeData;
}

Map<String, dynamic> $CountryCodeDataToJson(CountryCodeData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['params'] = entity.params?.toJson();
  data['id'] = entity.id;
  data['countryName'] = entity.countryName;
  data['countryNameZh'] = entity.countryNameZh;
  data['countryCode'] = entity.countryCode;
  data['countryNameEn'] = entity.countryNameEn;
  data['nationalFlag'] = entity.nationalFlag;
  return data;
}

extension CountryCodeDataExtension on CountryCodeData {
  CountryCodeData copyWith({
    CountryCodeDataParams? params,
    int? id,
    String? countryName,
    String? countryNameZh,
    String? countryCode,
    String? countryNameEn,
    String? nationalFlag,
  }) {
    return CountryCodeData()
      ..params = params ?? this.params
      ..id = id ?? this.id
      ..countryName = countryName ?? this.countryName
      ..countryNameZh = countryNameZh ?? this.countryNameZh
      ..countryCode = countryCode ?? this.countryCode
      ..countryNameEn = countryNameEn ?? this.countryNameEn
      ..nationalFlag = nationalFlag ?? this.nationalFlag;
  }
}

CountryCodeDataParams $CountryCodeDataParamsFromJson(
    Map<String, dynamic> json) {
  final CountryCodeDataParams countryCodeDataParams = CountryCodeDataParams();
  return countryCodeDataParams;
}

Map<String, dynamic> $CountryCodeDataParamsToJson(
    CountryCodeDataParams entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  return data;
}

extension CountryCodeDataParamsExtension on CountryCodeDataParams {
}